#ifndef VMMODEL_H
#define VMMODEL_H

#include "block.hpp"
#include <vector>

enum ALGO { OPT, LRU, FIFO };

class VmModel {
public:
  VmModel(unsigned int page_size, unsigned int vm_n_block, unsigned int n_mem,
          ALGO algo);
  int simulate(std::vector<int> const &requests,
               std::vector<std::vector<mem_block>> &res);
  unsigned int get_mem_count() { return n_mem; }
  unsigned int get_page_size() { return page_size; }
  unsigned int get_vm_n_block() { return vm_n_block; }
  void clear_mem();

private:
  unsigned int page_size;
  unsigned int vm_n_block;
  unsigned int n_mem;
  std::vector<mem_block> mem;
  ALGO algo;
  int get_available(int target_num);
  int evict(std::vector<int> const &requests, int idx);
};

#endif